package com.spzx.order.api;

import com.spzx.common.core.domain.R;
import com.spzx.order.domain.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * Package: com.spzx.order.api
 *
 * @author xiongkunYang
 * @description:
 * @since 2025/6/9 11:51
 */
@Component
@Slf4j
public class RemoteOrderInfoFallbackFactory implements FallbackFactory<RemoteOrderInfoService> {

    @Override
    public RemoteOrderInfoService create(Throwable throwable) {
        log.error("订单服务调用失败:{}", throwable.getMessage());
        return new RemoteOrderInfoService() {

            @Override
            public R<OrderInfo> getByOrderNo(String orderNo, String source) {
                return R.fail("根据订单号获取订单信息失败:" + throwable.getMessage());
            }
        };
    }
}